package com.hankol.message.adapter

import com.baselibrary.extension.checkValue
import com.baselibrary.utils.GlideUtils
import com.baselibrary.utils.TimeUtil
import com.baselibrary.view.RoundCornerImageView
import com.baselibrary.view.VipHeardImgView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.message.R
import com.hankol.message.bean.LikeAndCollectBean

/*点赞和收藏列表
* */
class LikeAndCollectAdapter : BaseQuickAdapter<LikeAndCollectBean, BaseViewHolder>(R.layout.item_like_and_collect) {

    override fun convert(helper: BaseViewHolder, item: LikeAndCollectBean) {
        helper.apply {
            //头像
            getView<VipHeardImgView>(R.id.img_heard).setData(item.icon.checkValue(), item.isFans == 1)
            //昵称
            setText(R.id.tv_nick, item.name.checkValue())
            //是否好友
            setGone(R.id.tv_tag_friend, item.isFriend==1)
            //封面图
            GlideUtils.loadImg_101(mContext, item.timelineCover.checkValue(), getView<RoundCornerImageView>(R.id.riv_cover))
            //是否 视频动态
            setGone(R.id.img_is_video, item.timelineShowtype==2)
            setText(R.id.tv_option_tip, showTipStr(item.btype))
            //时间
            setText(R.id.tv_option_time, TimeUtil.fromToday(item.ctime))
            //评论内容
            setText(R.id.tv_comment, item.commentContent.checkValue())
            setGone(R.id.ll_comment,item.btype==2)
            addOnClickListener(R.id.img_heard)
            addOnClickListener(R.id.ll_nick)
        }
    }
    //描述：1-赞了我的动态，2-赞了我的评论，3-收藏了我的动态
    fun showTipStr(type: Int): String {
        var str = ""
        when (type) {
            1 -> {
                str = "赞了我的动态"
            }
            2 -> {
                str = "赞了我的评论"
            }
            3 -> {
                str = "收藏了我的动态"
            }
        }
        return str
    }
}